<template>
  <div>
    <van-nav-bar title="moment.js示例" class="nav-bar" left-arrow @click-left="navToBack"/>
    <div class="content">
      <div class="block">
        <van-row>
          <van-col span="8"><van-button type="info" @click="onFormatDate()">格式化时间</van-button></van-col>
          <van-col span="8"><van-button type="info" @click="onCalcuTime()">计算时间</van-button></van-col>
        </van-row>
      </div>
    </div>
  </div>
</template>
<script>
import common from '@/mixins/common'
import moment from 'moment'
import 'moment/locale/zh-cn'
export default {
  mixins: [common],
  methods: {
    onFormatDate () {
      const formatDate = moment().format('YYYY-MM-DD HH:mm:ss')
      console.log(formatDate)
    },
    onCalcuTime (value) {
      const formatDate = moment('2020-06-18 12:00:00').format('YYYY-MM-DD HH:mm:ss')
      const calcuTime = moment(formatDate).startOf('minute').fromNow()
      console.log(calcuTime)
    }
  }
}
</script>
